import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { render } from '/@/utils/common/renderUtils';
import { defHttp } from '/@/utils/http/axios';
import { getToken } from '/@/utils/auth';
import { message } from 'ant-design-vue';

import JCascader from '/@/components/Form/src/jeecg/components/JCascader.vue';
import JTreeDict from '/@/components/Form/src/jeecg/components/JTreeDict.vue';
import JDictSelectTag from '/@/components/Form/src/jeecg/components/JDictSelectTag.vue';
import JPopup from '/@/components/Form/src/jeecg/components/JPopup.vue';
import JSelectUser from '/@/components/Form/src/jeecg/components/JSelectUser.vue';
import DatePicker from 'ant-design-vue';

enum GoodsConfigApi {
  list = '/goodsconfig/whGoodsConfig/list',
}
/**
 * 通过分类获取到自定义字段的数据
 * @param categoryId
 * @returns
 */
export const fetchCustomFieldsByCategory = async (categoryId: string) => {
  try {
    const params = {
      goodsCategory: categoryId,
    };

    const result = await defHttp.get({ url: GoodsConfigApi.list, params });
    return result.records || result;
  } catch (error) {
    return [];
  }
};
/**
 * 根据字段内容生成表单所需字段对象
 * @param customFields
 * @returns
 */
export const generateCustomFieldSchemas = (customFields: any[]): FormSchema[] => {
  return customFields.map((field: any) => {
    // Determine component type based on field configuration
    let component = 'Input';
    let componentProps = {};

    // You can customize this based on your field configuration
    if (field.fieldType === 'TEXTAREA') {
      component = 'InputTextArea';
    } else if (field.fieldType === 'NUMBER') {
      component = 'InputNumber';
    } else if (field.fieldType === 'SELECT' && field.dictCode) {
      component = 'JDictSelectTag';
      componentProps = {
        dictCode: field.dictCode,
        placeholder: `请选择${field.fieldLabel}`,
        allowClear: true,
        showSearch: true,
      };
    } else if (field.fieldType === 'DATE') {
      component = 'DatePicker';
      componentProps = {
        format: 'YYYY-MM-DD',
        showTime: true,
      };
    }

    return {
      field: field.fieldCode || field.id, // Use fieldCode or id as field name
      label: field.fieldLabel,
      component,
      componentProps,
      colProps: { span: 8 },
      helpMessage: field.helpMessage || '',
    };
  });
};
export const useCategoryCustomFields = () => {
  const updateFormSchemaWithCustomFields = async (categoryId: string) => {
    let enhancedSchema = [...formSchema];
    // console.log('获取到分类的编码:', enhancedSchema, categoryId);
    if (!categoryId) return;

    try {
      const customFields = await fetchCustomFieldsByCategory(categoryId);
      // console.log('获取到自定义字段:', customFields);

      if (customFields.length > 0) {
        enhancedSchema.push({
          field: 'customFieldsDivider',
          component: 'Divider',
          label: '自定义字段',
          componentProps: {
            orientation: 'left',
          },
          colProps: { span: 24 },
        });

        // Add custom field schemas
        enhancedSchema = [...enhancedSchema, ...customFieldSchemas];
      }
    } catch (error) {
      console.error('Failed to update form with custom fields:', error);
    }
  };

  return {
    updateFormSchemaWithCustomFields,
  };
};
export const columns: BasicColumn[] = [
  {
    title: '产品id',
    dataIndex: 'id',
    ifShow: false,
  },
  {
    title: '产品简图',
    dataIndex: 'coverPic',
    slots: { customRender: 'img' },
  },
  // {
  //   title: '自定义编码',
  //   dataIndex: 'customizeCode',
  //   edit: true,
  //   editable: false,
  // },
  {
    title: '产品编码',
    dataIndex: 'goodsCode',
  },
  {
    title: '产品中文名',
    dataIndex: 'goodsName',
    // edit: true,
    editable: false,
    width: 400,
    // customRender: ({ text }) => {
    //   return h(
    //     'span',
    //     {
    //       class: 'text-two-lines',
    //       title: text,
    //     },
    //     text
    //   );
    // },
  },
  {
    title: '产品中文简称',
    dataIndex: 'goodsNameCn',
    // edit: true,
    // editable: false,
    width: 400,
  },
  // {
  //   title: '产品分类',
  //   dataIndex: 'categoryId_dictText',
  // },
  {
    title: '厂商',
    dataIndex: 'goodsBrand_dictText',
  },
  // {
  //   title: '适配品牌',
  //   dataIndex: 'compatibleBrand',
  // },
  // {
  //   title: '适配型号',
  //   dataIndex: 'compatibleModel',
  // },
  // {
  //   title: '产品物流属性',
  //   dataIndex: 'goodsLogistics',
  // },
  // {
  //   title: '产品材质',
  //   dataIndex: 'productMaterial',
  // },
  // {
  //   title: '包装',
  //   dataIndex: 'packaging',
  // },
  // {
  //   title: '质量',
  //   dataIndex: 'quality',
  // },
  //{
  // title: '产品单位',
  //  dataIndex: 'goodsUnit_dictText',
  //},
  // {
  //   title: '质量默认仓库',
  //   dataIndex: 'defaultWarehouse',
  // },
  // {
  //   title: '默认货位',
  //   dataIndex: 'defaultLocation',
  // },
  {
    title: '采购人员',
    dataIndex: 'procurementPersonnel_dictText',
  },
  {
    title: '开发人员',
    dataIndex: 'developers_dictText',
  },
  {
    title: '负责人员',
    dataIndex: 'responsibleOfficer_dictText',
  },
  {
    title: '产品状态',
    dataIndex: 'goodsStatus',
    customRender: ({ text }) => {
      return render.renderDict(text, 'goods_status');
    },
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
  },
];

export const searchFormSchema: FormSchema[] = [
  // {
  //   label: '自定义编码',
  //   field: 'customizeCode',
  //   component: 'Input',
  //   helpMessage: ['系统中的产品编码'],
  // },
  {
    label: '产品编码',
    field: 'goodsCode',
    component: 'JInput',
    helpMessage: ['对应T+系统“存货编码”'],
  },
  {
    label: '产品名称',
    field: 'goodsName',
    component: 'JInput',
    helpMessage: ['对应T+系统“中文名称”'],
  },
  {
    label: '创建时间',
    field: 'careateTime',
    component: 'RangeDate',
    componentProps: {
      // showTime: true,
      format: 'YYYY/MM/DD HH:mm:ss',
    },
  },
];

// 高级查询条件下拉
export const superQuerySchema: FormSchema[] = [
  {
    label: '',
    field: 'left',
    component: 'Input',
    slot: 'add',
  },
];
// 高级查询数据
// export const superQueryOptions = {
//   goodsInfo: {
//     title: '基本信息',
//     view: 'table',
//     fields: {
//       goodsCode: { title: '产品编码', order: 0, view: 'text', type: 'string' },
//       goodsNameCn: { title: '产品中文简称', order: 1, view: 'text', type: 'string', dictCode: '' },
//       goodsName: { title: '产品名称', order: 2, view: 'text', type: 'string' },
//       categoryId: { title: '产品分类', order: 3, view: 'list', type: 'string' },
//       goodsBrand: { title: '厂商', order: 5, view: 'list', type: 'string' },
//       compatibleBrand: { title: '适用品牌', order: 6, view: 'list', type: 'string' },
//       compatibleModel: { title: '适配型号', order: 7, view: 'list', type: 'string' },
//       inventoryAttributes: { title: '产品侵权风险', order: 7, view: 'list', type: 'string' },
//       referenceLink: { title: '参考网站链接', order: 7, view: 'text', type: 'string' },
//       productFeatures: { title: '产品特点', order: 7, view: 'text', type: 'string' },
//       remark: { title: '适配型号', order: 7, view: 'text', type: 'string' },
//       goodsLogistics: { title: '产品物流属性', order: 7, view: 'list', type: 'string' },
//       productMaterial: { title: '产品材质', order: 7, view: 'list', type: 'string' },
//       valueType: { title: '计量方式', order: 7, view: 'list', type: 'string' },
//       goodsUnit: { title: '计量单位', order: 7, view: 'list', type: 'string' },
//       packaging: { title: '包装', order: 7, view: 'list', type: 'string' },
//       quality: { title: '质量', order: 7, view: 'list', type: 'string' },
//       labelModel: { title: '标签型号', order: 7, view: 'list', type: 'string' },
//       labelQuality: { title: '标签质量', order: 7, view: 'list', type: 'string' },
//       warehouse_name: { title: '默认仓库', order: 7, view: 'text', type: 'string' },
//       location_name: { title: '默认货位', order: 7, view: 'text', type: 'string' },
//       procurementPersonnel: { title: '采购人员', order: 7, view: 'list', type: 'string' },
//       developers: { title: '开发人员', order: 7, view: 'list', type: 'string' },
//       responsibleOfficer: { title: '负责人员', order: 7, view: 'list', type: 'string' },
//       createTime: { title: '创建时间', order: 7, view: 'date', type: 'string' },
//     },
//   },
//   goodsPrice: {
//     title: '产品价格',
//     view: 'table',
//     fields: {
//       supplySituation: { title: '供应情况', order: 7, view: 'list', type: 'string' },
//       supplier: { title: '供应商', order: 7, view: 'text', type: 'string' },
//       supplier_code: { title: '供应商编码', order: 7, view: 'text', type: 'string' },
//       mainlandCost: { title: '大陆成本', order: 7, view: 'text', type: 'string' },
//       MainlandProfitMargin: { title: '大陆利润率', order: 7, view: 'text', type: 'string' },
//       hkCost: { title: '香港成本', order: 7, view: 'text', type: 'string' },
//       hkProfitMargin: { title: '香港利润率', order: 7, view: 'text', type: 'string' },
//     },
//   },
//   goodsSale: {
//     title: '电商平台销售价格',
//     view: 'table',
//     fields: {
//       ebayProfitMargin: { title: 'eBay利润率', order: 7, view: 'text', type: 'string' },
//       ebayReferencePrice: { title: 'eBay参考单价', order: 7, view: 'text', type: 'string' },
//       aliExpressProfitMargin: { title: '速卖通利润率', order: 7, view: 'text', type: 'string' },
//       aliExpressReferencePrice: { title: '速卖通参考单价', order: 7, view: 'text', type: 'string' },
//     },
//   },
//   goodsEnglish: {
//     title: '产品英文资料',
//     view: 'table',
//     fields: {
//       englishName: { title: '英文名称', order: 7, view: 'text', type: 'string' },
//       englishShortName: { title: '产品英文简称', order: 7, view: 'text', type: 'string' },
//       websiteTitle: { title: '公司网站产品标题', order: 7, view: 'text', type: 'string' },
//       websiteDescription: { title: '公司网站产品详细描述', order: 7, view: 'text', type: 'string' },
//       productFeatures: { title: '产品特征亮点提取', order: 7, view: 'text', type: 'string' },
//     },
//   },
//   goodsDeliver: {
//     title: '产品发货',
//     view: 'table',
//     fields: {
//       actualWeight: { title: '实际重量', order: 7, view: 'text', type: 'string' },
//       HYCweight: { title: '包裹重量(g)', order: 7, view: 'text', type: 'string' },
//       packagingType: { title: '默认发货包材', order: 7, view: 'text', type: 'string' },
//       length: { title: '长(cm)', order: 7, view: 'text', type: 'string' },
//       width: { title: '宽(cm)', order: 7, view: 'text', type: 'string' },
//       height: { title: '高(cm)', order: 7, view: 'text', type: 'string' },
//       volumeWeight: { title: '产品体积', order: 7, view: 'text', type: 'string' },
//       packagingId: { title: '默认发货包材ID', order: 7, view: 'text', type: 'string' },
//     },
//   },
// };
export const superQueryOptions = {
  goodsInfo_goodsCode: { title: '产品编码', order: 0, view: 'text', type: 'string', value: 'goodsInfo_goodsCode' },
  goodsInfo_goodsNameCn: { title: '产品中文简称', order: 1, view: 'text', type: 'string', value: 'goodsInfo_goodsNameCn' },
  goodsInfo_goodsName: { title: '产品名称', order: 2, view: 'text', type: 'string', value: 'goodsInfo_goodsName' },
  goodsInfo_categoryId: {
    title: '产品分类',
    order: 3,
    view: 'list',
    type: 'string',
    value: 'goodsInfo_categoryId',
    component: JCascader,
    componentProps: {
      async: false,
      parentCode: 'C06',
      field: 'code',
      placeholder: '请选择产品分类',
      allowClear: true,
      showSearch: true,
      fieldNames: {
        label: 'title',
        value: 'code',
      },
    },
  },
  goodsInfo_goodsBrand: {
    title: '厂商',
    order: 5,
    view: 'list',
    type: 'string',
    value: 'goodsInfo_goodsBrand',
    // component: JTreeDict,
    // componentProps: {
    //   async: true,
    //   parentCode: 'C03',
    //   field: 'code',
    //   placeholder: '请选择厂商',
    //   allowClear: true,
    //   showSearch: true,
    // },
    component: JDictSelectTag,
    componentProps: {
      dictCode: 'PP',
      placeholder: '请选择厂商',
      allowClear: true,
      showSearch: true,
    },
  },
  goodsInfo_compatibleBrand: {
    title: '适用品牌',
    order: 6,
    view: 'list',
    type: 'string',
    value: 'goodsInfo_compatibleBrand',
    // component: JTreeDict,
    // componentProps: {
    //   async: true,
    //   parentCode: 'C05',
    //   field: 'code',
    //   placeholder: '请选择适用品牌',
    //   allowClear: true,
    //   showSearch: true,
    // },
    component: JDictSelectTag,
    componentProps: {
      dictCode: 'SPPP',
      placeholder: '请选择适用品牌',
      allowClear: true,
      showSearch: true,
    },
  },
  goodsInfo_compatibleModel: {
    title: '适配型号',
    order: 7,
    view: 'list',
    type: 'string',
    value: 'goodsInfo_compatibleModel',
    component: JDictSelectTag,
    componentProps: {
      dictCode: 'XH',
      placeholder: '请选择适配型号',
      allowClear: true,
      showSearch: true,
    },
  },
  goodsInfo_inventoryAttributes: {
    title: '产品侵权风险',
    order: 7,
    view: 'list',
    type: 'string',
    value: 'goodsInfo_inventoryAttributes',
    component: JDictSelectTag,
    componentProps: {
      dictCode: 'XZ',
      placeholder: '请选择侵权风险等级',
      allowClear: true,
      showSearch: true,
    },
  },
  goodsInfo_referenceLink: { title: '参考网站链接', order: 7, view: 'text', type: 'string', value: 'goodsInfo_referenceLink' },
  goodsInfo_productFeatures: { title: '产品特点', order: 7, view: 'text', type: 'string', value: 'goodsInfo_productFeatures' },
  goodsInfo_remark: { title: '适配型号', order: 7, view: 'text', type: 'string', value: 'goodsInfo_remark' },
  goodsInfo_goodsLogistics: {
    title: '产品物流属性',
    order: 7,
    view: 'list',
    type: 'string',
    value: 'goodsInfo_goodsLogistics',
    component: JDictSelectTag,
    componentProps: {
      dictCode: 'HDHHY',
      placeholder: '请选择产品物流属性',
      allowClear: true,
      showSearch: true,
    },
  },
  goodsInfo_productMaterial: {
    title: '产品材质',
    order: 7,
    view: 'list',
    type: 'string',
    value: 'goodsInfo_productMaterial',
    component: JDictSelectTag,
    componentProps: {
      dictCode: 'XFPP',
      placeholder: '请选择产品材质',
      allowClear: true,
      showSearch: true,
    },
  },
  goodsInfo_valueType: {
    title: '计量方式',
    order: 7,
    view: 'list',
    type: 'string',
    value: 'goodsInfo_valueType',
    component: JDictSelectTag,
    componentProps: {
      dictCode: 'JJFS',
      placeholder: '请选择计量方式',
      allowClear: true,
      showSearch: true,
    },
  },
  goodsInfo_goodsUnit: {
    title: '计量单位',
    order: 7,
    view: 'list',
    type: 'string',
    value: 'goodsInfo_goodsUnit',
    component: JDictSelectTag,
    componentProps: {
      dictCode: 'DW',
      placeholder: '请选择计量单位',
      allowClear: true,
      showSearch: true,
    },
  },
  goodsInfo_packaging: {
    title: '包装',
    order: 7,
    view: 'list',
    type: 'string',
    value: 'goodsInfo_packaging',
    component: JDictSelectTag,
    componentProps: {
      dictCode: 'SF', // 需要根据实际的字典编码进行调整
      placeholder: '请选择包装方式',
      allowClear: true,
      showSearch: true,
    },
  },
  goodsInfo_quality: {
    title: '质量',
    order: 7,
    view: 'list',
    type: 'string',
    value: 'goodsInfo_quality',
    component: JDictSelectTag,
    componentProps: {
      dictCode: 'ZL', // 需要根据实际的字典编码进行调整
      placeholder: '请选择包装方式',
      allowClear: true,
      showSearch: true,
    },
  },
  goodsInfo_labelModel: {
    title: '标签型号',
    order: 7,
    view: 'list',
    type: 'string',
    value: 'goodsInfo_labelModel',
    component: JDictSelectTag,
    componentProps: {
      dictCode: 'BQXH',
      placeholder: '请选择标签型号',
      llowClear: true,
      showSearch: true,
      // mode: 'multiple',
    },
  },
  goodsInfo_labelQuality: {
    title: '标签质量',
    order: 7,
    view: 'list',
    type: 'string',
    value: 'goodsInfo_labelQuality',
    component: JDictSelectTag,
    componentProps: {
      dictCode: 'BQZL',
      placeholder: '请选择标签质量',
      // mode: 'multiple',
    },
  },
  goodsInfo_warehouse_name: {
    title: '默认仓库',
    order: 7,
    view: 'text',
    type: 'string',
    value: 'goodsInfo_warehouse_name',
    component: JPopup,
    componentProps: {
      placeholder: '请选择默认仓库',
      code: 'warehouse_popup',
      fieldConfig: [
        { source: 'warehouse_code', target: 'defaultWarehouse_code' },
        { source: 'warehouse_name', target: 'defaultWarehouse' },
      ],
      multi: false,
    },
  },
  goodsInfo_location_name: {
    title: '默认货位',
    order: 7,
    view: 'text',
    type: 'string',
    value: 'goodsInfo_location_name',
    component: JPopup,
    componentProps: ({ formActionType, formModel }) => {
      console.log('formModel', formModel);
      const { setFieldsValue } = formActionType;
      const warehouseCode = formModel.defaultWarehouse_code;
      return {
        setFieldsValue,
        placeholder: '请选择',
        code: 'location_popup',
        fieldConfig: [
          { source: 'location_code', target: 'defaultLocation_code' },
          { source: 'location_name', target: 'defaultLocation' },
        ],
        multi: false,
        ...(warehouseCode
          ? {
              queryParam: { warehouse_belongs_to: warehouseCode },
            }
          : {}),
      };
    },
  },
  goodsInfo_procurementPersonnel: {
    title: '采购人员',
    order: 7,
    view: 'list',
    type: 'string',
    value: 'goodsInfo_procurementPersonnel',
    component: JSelectUser,
    componentProps: {
      placeholder: '请选择采购人员',
      isRadioSelection: true,
      labelKey: 'realname',
      rowKey: 'id',
    },
  },
  goodsInfo_developers: {
    title: '开发人员',
    order: 7,
    view: 'list',
    type: 'string',
    value: 'goodsInfo_developers',
    component: JSelectUser,
    componentProps: {
      placeholder: '请选择开发人员',
      isRadioSelection: true,
      labelKey: 'realname',
      rowKey: 'id',
    },
  },
  goodsInfo_responsibleOfficer: {
    title: '负责人员',
    order: 7,
    view: 'list',
    type: 'string',
    value: 'goodsInfo_responsibleOfficer',
    component: JSelectUser,
    componentProps: {
      placeholder: '请选择负责人员',
      isRadioSelection: true,
      labelKey: 'realname',
      rowKey: 'id',
    },
  },
  goodsInfo_createTime: {
    title: '创建时间',
    order: 7,
    view: 'date',
    type: 'string',
    value: 'goodsInfo_createTime',
    component: DatePicker,
    componentProps: {
      showTime: true,
      format: 'YYYY-MM-DD HH:mm:ss',
      disabled: true, // 禁止编辑
    },
  },
  goodsPrice_supplySituation: {
    title: '供应情况',
    order: 7,
    view: 'list',
    type: 'string',
    value: 'goodsPrice_supplySituation',
    component: JDictSelectTag,
    componentProps: {
      dictCode: 'GYQK',
      placeholder: '请选择供应情况',
      allowClear: true,
      showSearch: true,
    },
  },
  goodsPrice_supplier: {
    title: '供应商',
    order: 7,
    view: 'text',
    type: 'string',
    value: 'goodsPrice_supplier',
    component: JPopup,
    componentProps: ({ formActionType }) => {
      const { setFieldsValue } = formActionType;
      return {
        setFieldsValue,
        placeholder: '请选择',
        code: 'supplier',
        fieldConfig: [
          { source: 'code', target: 'supplier_code' },
          { source: 'name', target: 'supplier' },
        ],
        multi: false,
      };
    },
  },
  goodsPrice_supplier_code: { title: '供应商编码', order: 7, view: 'text', type: 'string', value: 'goodsPrice_supplier_code' },
  goodsPrice_mainlandCost: { title: '大陆成本', order: 7, view: 'text', type: 'string', value: 'goodsPrice_mainlandCost' },
  goodsPrice_MainlandProfitMargin: { title: '大陆利润率', order: 7, view: 'text', type: 'string', value: 'goodsPrice_MainlandProfitMargin' },
  goodsPrice_hkCost: { title: '香港成本', order: 7, view: 'text', type: 'string', value: 'goodsPrice_hkCost' },
  goodsPrice_hkProfitMargin: { title: '香港利润率', order: 7, view: 'text', type: 'string', value: 'goodsPrice_hkProfitMargin' },
  goodsSale_ebayProfitMargin: { title: 'eBay利润率', order: 7, view: 'text', type: 'string', value: 'goodsSale_ebayProfitMargin' },
  goodsSale_ebayReferencePrice: { title: 'eBay参考单价', order: 7, view: 'text', type: 'string', value: 'goodsSale_ebayReferencePrice' },
  goodsSale_aliExpressProfitMargin: { title: '速卖通利润率', order: 7, view: 'text', type: 'string', value: 'goodsSale_aliExpressProfitMargin' },
  goodsSale_aliExpressReferencePrice: {
    title: '速卖通参考单价',
    order: 7,
    view: 'text',
    type: 'string',
    value: 'goodsSale_aliExpressReferencePrice',
  },
  goodsEnglish_englishName: { title: '英文名称', order: 7, view: 'text', type: 'string', value: 'goodsEnglish_englishName' },
  goodsEnglish_englishShortName: { title: '产品英文简称', order: 7, view: 'text', type: 'string', value: 'goodsEnglish_englishShortName' },
  goodsEnglish_websiteTitle: { title: '公司网站产品标题', order: 7, view: 'text', type: 'string', value: 'goodsEnglish_websiteTitle' },
  goodsEnglish_websiteDescription: {
    title: '公司网站产品详细描述',
    order: 7,
    view: 'text',
    type: 'string',
    value: 'goodsEnglish_websiteDescription',
  },
  goodsEnglish_productFeatures: { title: '产品特征亮点提取', order: 7, view: 'text', type: 'string', value: 'goodsEnglish_productFeatures' },
  goodsEnglish_itemColor: {
    title: '颜色',
    order: 7,
    view: 'text',
    type: 'string',
    value: 'goodsEnglish_itemColor',
    component: JDictSelectTag,
    componentProps: {
      dictCode: 'ItemColor',
      placeholder: '请选择颜色',
      allowClear: true,
      showSearch: true,
    },
  },
  goodsDeliver_actualWeight: { title: '实际重量', order: 7, view: 'text', type: 'string', value: 'goodsDeliver_actualWeight' },
  goodsDeliver_HYCweight: { title: '包裹重量(g)', order: 7, view: 'text', type: 'string', value: 'goodsDeliver_HYCweight' },
  goodsDeliver_packagingType: {
    title: '默认发货包材',
    order: 7,
    view: 'text',
    type: 'string',
    value: 'goodsDeliver_packagingType',
    component: JPopup,
    componentProps: ({ formActionType }) => {
      const { setFieldsValue } = formActionType;
      return {
        setFieldsValue,
        placeholder: '请选择',
        code: 'packaging_popup',
        fieldConfig: [
          { source: 'type', target: 'packagingType' },
          { source: 'id', target: 'packagingId' },
        ],
        multi: false,
      };
    },
  },
  goodsDeliver_length: { title: '长(cm)', order: 7, view: 'text', type: 'string', value: 'goodsDeliver_length' },
  goodsDeliver_width: { title: '宽(cm)', order: 7, view: 'text', type: 'string', value: 'goodsDeliver_width' },
  goodsDeliver_height: { title: '高(cm)', order: 7, view: 'text', type: 'string', value: 'goodsDeliver_height' },
  goodsDeliver_volumeWeight: { title: '产品体积', order: 7, view: 'text', type: 'string', value: 'goodsDeliver_volumeWeight' },
  goodsDeliver_packagingId: { title: '默认发货包材ID', order: 7, view: 'text', type: 'string', value: 'goodsDeliver_packagingId' },
};

export const formSchema: FormSchema[] = [
  // TODO 主键隐藏字段，目前写死为ID
  { label: '', field: 'id', component: 'Input', show: false },
  // {
  //   label: '自定义编码',
  //   field: 'customizeCode',
  //   component: 'Input',
  //   colProps: { span: 8 },
  //   helpMessage: ['商家自己的自定义编码'],
  // },
  {
    label: '产品编码',
    field: 'goodsCode',
    component: 'Input',
    colProps: { span: 8 },
    componentProps: ({ formModel }) => {
      return {
        disabled: !!formModel.id, // Disable if ID exists (editing mode)
      };
    },
    helpMessage: ['对应T+系统“存货编码”'],
    required: true,
  },
  {
    label: '产品中文简称',
    field: 'goodsNameCn',
    component: 'Input',
    colProps: { span: 8 },
    helpMessage: ['对应T+系统自定义项“中文简称”'],
  },
  {
    label: '产品名称',
    field: 'goodsName',
    component: 'Input',
    colProps: { span: 8 },
    helpMessage: ['对应T+系统“中文名称”'],
    required: true,
  },
  {
    field: 'categoryId',
    label: '产品分类',
    component: 'JCascader',
    componentProps: {
      async: false,
      parentCode: 'C06',
      field: 'code',
      placeholder: '请选择产品分类',
      allowClear: true,
      showSearch: true,
      fieldNames: {
        label: 'title',
        value: 'code',
      },
    },
    colProps: { span: 8 },
    required: true,
  },
  {
    field: 'goodsBrand',
    label: '厂商',
    // component: 'JTreeDict',
    // componentProps: {
    //   async: true,
    //   parentCode: 'C03',
    //   field: 'code',
    //   placeholder: '请选择厂商',
    //   allowClear: true,
    //   showSearch: true,
    // },
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'PP',
      placeholder: '请选择厂商',
      allowClear: true,
      showSearch: true,
    },
    colProps: { span: 8 },
    required: true,
  },
  {
    field: 'compatibleBrand',
    label: '适用品牌',
    // component: 'JTreeDict',
    // componentProps: {
    //   async: true,
    //   parentCode: 'C05',
    //   field: 'code',
    //   placeholder: '请选择适用品牌',
    //   allowClear: true,
    //   showSearch: true,
    // },
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'SPPP',
      placeholder: '请选择适用品牌',
      allowClear: true,
      showSearch: true,
    },
    colProps: { span: 8 },
    required: true,
  },
  {
    field: 'compatibleModel',
    label: '适配型号',
    helpMessage: '对应T+系统自定义项“型号”',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'XH',
      placeholder: '请选择适配型号',
      allowClear: true,
      showSearch: true,
    },
    colProps: { span: 8 },
  },
  {
    // field: 'infringementRisk',
    field: 'inventoryAttributes',
    label: '产品侵权风险',
    helpMessage: '对应T+系统自定义项“性质”',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'XZ',
      placeholder: '请选择侵权风险等级',
      allowClear: true,
      showSearch: true,
    },
    colProps: { span: 8 },
  },
  {
    field: 'referenceLink',
    label: '参考网站链接',
    component: 'Input',
    helpMessage: '可参考的产品链接供他人查阅',
    colProps: { span: 8 },
  },

  {
    field: 'productFeatures',
    label: '产品特点',
    component: 'InputTextArea',
    helpMessage: '产品的详细信息，供作图与编写资料参考',
    colProps: { span: 24 },
  },
  {
    field: 'remark',
    label: '产品备注',
    helpMessage: '报价单需备注的事项',
    component: 'InputTextArea',
    colProps: { span: 24 },
  },
  {
    field: 'goodsLogistics',
    label: '产品物流属性',
    helpMessage: '对应T+系统自定义项“含电或含液”',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'HDHHY',
      placeholder: '请选择产品物流属性',
      allowClear: true,
      showSearch: true,
    },
    colProps: { span: 8 },
  },
  {
    field: 'productMaterial',
    label: '产品材质',
    component: 'JDictSelectTag',
    helpMessage: '对应T+系统“材质/细分品牌”，但是T+里面的是混在一起填的',
    componentProps: {
      dictCode: 'XFPP',
      placeholder: '请选择产品物流属性',
      allowClear: true,
      showSearch: true,
    },
    colProps: { span: 8 },
  },
  // {
  //   field: 'productCertification',
  //   label: '产品认证资质',
  //   component: 'JDictSelectTag',
  //   componentProps: {
  //     dictCode: 'product_certification',
  //     placeholder: '请选择产品物流属性',
  //     allowClear: true,
  //     showSearch: true,
  //     mode: 'multiple',
  //   },
  //   colProps: { span: 8 },
  // },
  {
    field: 'valueType',
    label: '计量方式',
    helpMessage: '对应T+系统自定义项“计量方式”',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'JJFS',
      placeholder: '请选择计量方式',
      allowClear: true,
      showSearch: true,
    },
    colProps: { span: 8 },
    required: true,
  },
  {
    field: 'goodsUnit',
    label: '计量单位',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'DW',
      placeholder: '请选择计量单位',
      allowClear: true,
      showSearch: true,
    },
    colProps: { span: 8 },
    required: true,
  },
  {
    field: 'packaging',
    label: '包装',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'SF', // 需要根据实际的字典编码进行调整
      placeholder: '请选择包装方式',
      allowClear: true,
      showSearch: true,
    },
    colProps: { span: 8 },
  },
  {
    field: 'quality',
    label: '质量',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'ZL', // 需要根据实际的字典编码进行调整
      placeholder: '请选择包装方式',
      allowClear: true,
      showSearch: true,
    },
    colProps: { span: 8 },
  },
  {
    field: 'inventoryAttributesTitle',
    label: '系统的存货属性',
    component: 'Divider',
    componentProps: {
      orientation: 'left',
    },
    colProps: { span: 24 },
  },
  {
    field: 'isEshop',
    label: '电商',
    component: 'Checkbox',
    colProps: { span: 2 },
    defaultValue: false,
    componentProps: {
      label: '电商',
    },
  },
  {
    field: 'isPurchase',
    label: '外购',
    component: 'Checkbox',
    componentProps: {
      label: '外购属性',
    },
    colProps: { span: 2 },
    defaultValue: false,
  },
  {
    field: 'isSale',
    label: '销售',
    component: 'Checkbox',
    componentProps: {
      label: '销售属性',
    },
    colProps: { span: 2 },
    defaultValue: false,
  },
  {
    field: 'isMadeSelf',
    label: '自制',
    component: 'Checkbox',
    componentProps: {
      label: '自制',
    },
    colProps: { span: 2 },
    defaultValue: false,
  },
  {
    field: 'isMaterial',
    label: '生产耗用',
    component: 'Checkbox',
    componentProps: {
      label: '生产耗用',
    },
    colProps: { span: 2 },
    defaultValue: false,
  },
  {
    field: 'isLaborCost',
    label: '劳务',
    component: 'Checkbox',
    componentProps: {
      label: '劳务',
    },
    colProps: { span: 2 },
    defaultValue: false,
  },
  {
    field: 'isMadeRequest',
    label: '委外',
    component: 'Checkbox',
    componentProps: {
      label: '委外',
    },
    colProps: { span: 2 },
    defaultValue: false,
  },
  {
    field: 'isPriceSheet',
    label: '报价单产品',
    component: 'Checkbox',
    componentProps: {
      label: '报价单产品',
    },
    colProps: { span: 2 },
    defaultValue: false,
  },
  {
    field: 'isOfficial',
    label: '官网产品',
    component: 'Checkbox',
    componentProps: {
      label: '官网产品',
    },
    colProps: { span: 2 },
    defaultValue: false,
  },
  {
    field: 'inventoryAttributesTitle2',
    label: '',
    component: 'Divider',
    componentProps: {
      orientation: 'left',
    },
    colProps: { span: 24 },
  },
  {
    field: 'labelModel',
    label: '标签型号',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'BQXH',
      placeholder: '请选择标签型号',
      llowClear: true,
      showSearch: true,
      // mode: 'multiple',
    },
    colProps: { span: 8 },
  },
  {
    field: 'labelQuality',
    label: '标签质量',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'BQZL',
      placeholder: '请选择标签质量',
      // mode: 'multiple',
    },
    colProps: { span: 8 },
  },
  {
    field: 'defaultWarehouse',
    label: '默认仓库',
    component: 'JPopup',
    componentProps: ({ formActionType }) => {
      const { setFieldsValue } = formActionType;
      return {
        setFieldsValue,
        placeholder: '请选择默认仓库',
        code: 'warehouse_popup',
        fieldConfig: [
          { source: 'warehouse_code', target: 'defaultWarehouse_code' },
          { source: 'warehouse_name', target: 'defaultWarehouse' },
        ],
        multi: false,
      };
    },
    colProps: { span: 8 },
  },
  {
    field: 'defaultWarehouse_code',
    label: '默认仓库',
    component: 'Input',
    colProps: { span: 8 },
    show: false,
  },
  {
    field: 'defaultLocation',
    label: '默认货位',
    component: 'JPopup',
    componentProps: ({ formActionType, formModel }) => {
      console.log('formModel', formModel);
      const { setFieldsValue } = formActionType;
      const warehouseCode = formModel.defaultWarehouse_code;
      return {
        setFieldsValue,
        placeholder: '请选择',
        code: 'location_popup',
        fieldConfig: [
          { source: 'location_code', target: 'defaultLocation_code' },
          { source: 'location_name', target: 'defaultLocation' },
        ],
        multi: false,
        ...(warehouseCode
          ? {
              queryParam: { warehouse_belongs_to: warehouseCode },
            }
          : {}),
      };
    },
    colProps: { span: 8 },
  },
  {
    field: 'defaultLocation_code',
    label: '默认货位',
    component: 'Input',
    colProps: { span: 8 },
    show: false,
  },
  // {
  //   field: 'barcodeScheme',
  //   label: '条码方案',
  //   component: 'JPopup',
  //   componentProps: ({ formActionType }) => {
  //     const { setFieldsValue } = formActionType;
  //     return {
  //       setFieldsValue,
  //       placeholder: '请选择',
  //       code: 'tmca_popup',
  //       fieldConfig: [
  //         { source: 'code', target: 'barcodeScheme_code' },
  //         { source: 'code_name', target: 'barcodeScheme' },
  //       ],
  //       multi: false,
  //     };
  //   },
  //   colProps: { span: 8 },
  // },
  // {
  //   field: 'barcodeScheme_code',
  //   label: '条码方案',
  //   component: 'Input',
  //   colProps: { span: 8 },
  //   show: false,
  // },
  {
    field: 'procurementPersonnel',
    label: '采购人员',
    component: 'JSelectUser',
    componentProps: {
      placeholder: '请选择采购人员',
      isRadioSelection: true,
      labelKey: 'realname',
      rowKey: 'id',
    },
    colProps: { span: 8 },
  },
  {
    field: 'developers',
    label: '开发人员',
    component: 'JSelectUser',
    componentProps: {
      placeholder: '请选择开发人员',
      isRadioSelection: true,
      labelKey: 'realname',
      rowKey: 'id',
    },
    colProps: { span: 8 },
  },
  {
    field: 'responsibleOfficer',
    label: '负责人员',
    component: 'JSelectUser',
    componentProps: {
      isRadioSelection: true,
      labelKey: 'realname',
      rowKey: 'id',
    },
    colProps: { span: 8 },
  },
  {
    label: '创建时间',
    field: 'createTime',
    component: 'DatePicker',
    helpMessage: '对应T+系统“建档日期”',
    componentProps: {
      showTime: true,
      format: 'YYYY-MM-DD HH:mm:ss',
      disabled: true, // 禁止编辑
    },
    colProps: { span: 8 },
  },
];
export const formSchema02: FormSchema[] = [
  { label: '', field: 'id', component: 'Input', show: false },
  {
    label: '产品编码',
    field: 'goodsCode',
    component: 'Input',
    show: false,
  },
  {
    label: '供应情况',
    field: 'supplySituation',
    component: 'JDictSelectTag',
    colProps: { span: 8 },
    helpMessage: '对应T+系统自定义项“供应情况',
    componentProps: {
      dictCode: 'GYQK',
      placeholder: '请选择供应情况',
      allowClear: true,
      showSearch: true,
    },
  },
  {
    field: 'supplier',
    label: '供应商',
    component: 'JPopup',
    componentProps: ({ formActionType }) => {
      const { setFieldsValue } = formActionType;
      return {
        setFieldsValue,
        placeholder: '请选择',
        code: 'supplier',
        fieldConfig: [
          { source: 'code', target: 'supplier_code' },
          { source: 'name', target: 'supplier' },
        ],
        multi: false,
      };
    },
    colProps: { span: 8 },
  },
  {
    field: 'supplier_code',
    label: '供应商编码',
    component: 'Input',
    colProps: { span: 8 },
    show: false,
  },
  {
    field: 'MainlandPrice',
    component: 'Divider',
    label: '大陆价格',
  },
  {
    field: 'mainlandCost',
    label: '大陆成本',
    component: 'InputNumber',
    colProps: { span: 8 },
    componentProps: {
      style: { width: '100%' }, // Ensure consistent width
    },
  },
  // {
  //   field: 'mainlandQuotation',
  //   label: '大陆报价',
  //   component: 'InputNumber',
  //   colProps: { span: 8 },
  //   componentProps: {
  //     style: { width: '100%' }, // Ensure consistent width
  //   },
  // },
  {
    field: 'MainlandProfitMargin',
    label: '大陆利润率',
    component: 'InputNumber',
    colProps: { span: 8 },
    componentProps: {
      style: { width: '100%' }, // Ensure consistent width
    },
  },
  {
    field: 'hkPrice',
    component: 'Divider',
    label: '香港价格',
  },
  {
    field: 'hkCost',
    label: '香港成本',
    component: 'InputNumber',
    colProps: { span: 8 },
    componentProps: {
      style: { width: '100%' }, // Ensure consistent width
    },
  },
  // {
  //   field: 'hkQuotation',
  //   label: '香港报价',
  //   component: 'InputNumber',
  //   colProps: { span: 8 },
  //   componentProps: {
  //     style: { width: '100%' }, // Ensure consistent width
  //   },
  // },
  {
    field: 'hkProfitMargin',
    label: '香港利润率',
    component: 'InputNumber',
    colProps: { span: 8 },
    componentProps: {
      style: { width: '100%' }, // Ensure consistent width
    },
  },
];
export const formSchema03: FormSchema[] = [
  { label: '', field: 'id', component: 'Input', show: false },
  {
    label: '产品编码',
    field: 'goodsCode',
    component: 'Input',
    show: false,
  },
  {
    field: 'hkPrice',
    component: 'Divider',
    label: 'eBay',
    componentProps: {
      orientation: 'left',
    },
  },
  {
    label: 'eBay利润率',
    field: 'ebayProfitMargin',
    component: 'InputNumber',
    colProps: { span: 8 },
    componentProps: {
      style: { width: '100%' },
    },
  },
  {
    label: 'eBay参考单价',
    field: 'ebayReferencePrice',
    component: 'InputNumber',
    colProps: { span: 8 },
    componentProps: {
      style: { width: '100%' },
    },
  },
  // {
  //   label: 'eBay批量参考售价',
  //   field: 'ebayBulkPrice',
  //   component: 'InputNumber',
  //   colProps: { span: 8 },
  //   componentProps: {
  //     style: { width: '100%' },
  //   },
  // },
  {
    field: 'hkPrice',
    component: 'Divider',
    label: '速卖通',
  },
  {
    label: '速卖通利润率',
    field: 'aliExpressProfitMargin',
    component: 'InputNumber',
    colProps: { span: 8 },
    componentProps: {
      style: { width: '100%' },
    },
  },
  {
    label: '速卖通参考单价',
    field: 'aliExpressReferencePrice',
    component: 'InputNumber',
    colProps: { span: 8 },
    componentProps: {
      style: { width: '100%' },
    },
  },
  // {
  //   label: '速卖通批量参考售价',
  //   field: 'aliExpressBulkPrice',
  //   component: 'InputNumber',
  //   colProps: { span: 8 },
  //   componentProps: {
  //     style: { width: '100%' },
  //   },
  // },
];
export const formSchema04: FormSchema[] = [
  { label: '', field: 'id', component: 'Input', show: false },
  {
    label: '产品编码',
    field: 'goodsCode',
    component: 'Input',
    show: false,
  },
  {
    label: '英文名称',
    field: 'englishName',
    component: 'Input',
    helpMessage: '对应T+系统“英文名称”',
    colProps: { span: 12 },
  },
  {
    label: '产品英文简称',
    field: 'englishShortName',
    component: 'Input',
    helpMessage: '对应T+系统自定义项“英文简称”',
    colProps: { span: 12 },
  },
  {
    label: '公司网站产品标题',
    field: 'websiteTitle',
    component: 'Input',
    helpMessage: '对应T+系统“网站描述”',
    colProps: { span: 12 },
  },
  {
    label: '公司网站产品详细描述',
    field: 'websiteDescription',
    component: 'InputTextArea',
    helpMessage: '公司网站产品详细描述',
    colProps: { span: 24 },
  },
  {
    label: '产品特征亮点提取',
    field: 'productFeatures',
    component: 'InputTextArea',
    helpMessage: '可用于报价单description栏',
    colProps: { span: 24 },
  },
  {
    field: 'itemColor',
    label: '颜色',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'ItemColor',
      placeholder: '请选择颜色',
      allowClear: true,
      showSearch: true,
    },
    colProps: { span: 8 },
  },
];
export const formSchema05: FormSchema[] = [
  { label: '', field: 'id', component: 'Input', show: false },
  {
    label: '产品编码',
    field: 'goodsCode',
    component: 'Input',
    show: false,
  },
  {
    field: 'hkPrice',
    component: 'Divider',
    label: '海外仓发货',
  },
  {
    label: '实际重量',
    field: 'actualWeight',
    component: 'InputNumber',
    colProps: { span: 8 },
    componentProps: {
      style: { width: '100%' }, // Ensure consistent width
    },
  },

  {
    label: '包裹重量(g)',
    field: 'HYCweight',
    component: 'InputNumber',
    colProps: { span: 8 },
    componentProps: {
      style: { width: '100%' }, // Ensure consistent width
    },
  },
  {
    field: 'packagingType',
    label: '默认发货包材',
    component: 'JPopup',
    componentProps: ({ formActionType }) => {
      const { setFieldsValue } = formActionType;
      return {
        setFieldsValue,
        placeholder: '请选择',
        code: 'packaging_popup',
        fieldConfig: [
          { source: 'type', target: 'packagingType' },
          { source: 'id', target: 'packagingId' },
        ],
        multi: false,
      };
    },
    colProps: { span: 8 },
  },
  // {
  //   label: '产品规格(cm)',
  //   field: 'HYCsize',
  //   component: 'InputNumber',
  //   colProps: { span: 8 },
  //   componentProps: {
  //     style: { width: '100%' }, // Ensure consistent width
  //   },
  // },
  {
    label: '长(cm)',
    field: 'length',
    component: 'InputNumber',
    colProps: { span: 8 },
    componentProps: {
      style: { width: '100%' },
      placeholder: '请输入长度',
    },
    dynamicRules: ({ model }) => {
      return [
        {
          validator(_, value) {
            if (value && model.width && model.height) {
              model.volumeWeight = (value * model.width * model.height).toFixed(2);
            }
            return Promise.resolve();
          },
        },
      ];
    },
  },
  {
    label: '宽(cm)',
    field: 'width',
    component: 'InputNumber',
    colProps: { span: 8 },
    componentProps: {
      style: { width: '100%' },
      placeholder: '请输入宽度',
    },
    dynamicRules: ({ model }) => {
      return [
        {
          validator(_, value) {
            if (value && model.length && model.height) {
              model.volumeWeight = ((model.length * value * model.height) / 5000).toFixed(2);
            }
            return Promise.resolve();
          },
        },
      ];
    },
  },
  {
    label: '高(cm)',
    field: 'height',
    component: 'InputNumber',
    colProps: { span: 8 },
    componentProps: {
      style: { width: '100%' },
      placeholder: '请输入高度',
    },
    dynamicRules: ({ model }) => {
      return [
        {
          validator(_, value) {
            if (value && model.length && model.width) {
              model.volumeWeight = (model.length * model.width * value).toFixed(2);
            }
            return Promise.resolve();
          },
        },
      ];
    },
  },
  {
    label: '产品体积',
    field: 'volumeWeight',
    component: 'InputNumber',
    colProps: { span: 8 },
    componentProps: {
      style: { width: '100%' },
      disabled: true,
    },
    dynamicDisabled: true,
  },
  {
    field: 'packagingId',
    label: '默认发货包材ID',
    component: 'Input',
    colProps: { span: 8 },
    show: false,
  },
];
export const formSchema06: FormSchema[] = [
  { label: '', field: 'id', component: 'Input', show: false },
  {
    label: '产品编码',
    field: 'goodsCode',
    component: 'Input',
    show: false,
  },
  {
    field: 'hkPrice',
    component: 'Divider',
    label: '产品简图',
  },
  {
    field: 'coverPic',
    component: 'JImageUpload',
    label: '',
    helpMessage: '采购在录初级资料的时候需要上传一张产品的初级图片，最多上传1张图片',
    componentProps: ({ formModel }) => {
      return {
        fileMax: 1,
        uploadPath: 's3',
        data: (file) => {
          return {
            fileType: 'A003',
            businessId: formModel.id || '',
            filename: file.name,
          };
        },
        headers: {
          Authorization: getToken(),
          'X-Access-Token': getToken(),
        },
        beforeUpload: (file) => {
          const isImage = file.type.startsWith('image/');
          if (!isImage) {
            message.error('只能上传图片!');
            return false; // Prevent upload
          }
          return isImage;
        },
      };
    },
  },
  {
    field: 'hkPrice',
    component: 'Divider',
    label: '公司网站图片',
  },
  {
    label: '',
    field: 'websitePic',
    helpMessage: '公司网站图片，最多上传15张图片',
    component: 'JImageUpload',
    componentProps: ({ formModel }) => {
      return {
        fileMax: 15,
        uploadPath: 's3',
        data: (file) => {
          return {
            fileType: 'A003',
            businessId: formModel.id || '',
            filename: file.name,
          };
        },
        headers: {
          Authorization: getToken(),
          'X-Access-Token': getToken(),
        },
        beforeUpload: (file) => {
          const isImage = file.type.startsWith('image/');
          if (!isImage) {
            message.error('只能上传图片!');
            return false; // Prevent upload
          }
          return isImage;
        },
      };
    },
  },
  {
    field: 'hkPrice',
    component: 'Divider',
    label: 'eBay平台图片',
  },
  {
    label: '',
    field: 'ebayPic',
    helpMessage: 'eBay平台图片，最多上传15张图片',
    component: 'JImageUpload',
    componentProps: ({ formModel }) => {
      return {
        fileMax: 15,
        uploadPath: 's3',
        data: (file) => {
          return {
            fileType: 'A003',
            businessId: formModel.id || '',
            filename: file.name,
          };
        },
        headers: {
          Authorization: getToken(),
          'X-Access-Token': getToken(),
        },
        beforeUpload: (file) => {
          const isImage = file.type.startsWith('image/');
          if (!isImage) {
            message.error('只能上传图片!');
            return false; // Prevent upload
          }
          return isImage;
        },
      };
    },
  },
  {
    field: 'hkPrice',
    component: 'Divider',
    label: '速卖通平台图片',
  },
  {
    label: '',
    field: 'aliExpressPic',
    helpMessage: '速卖通平台图片，最多上传15张图片',
    component: 'JImageUpload',
    componentProps: ({ formModel }) => {
      return {
        fileMax: 15,
        uploadPath: 's3',
        data: (file) => {
          return {
            fileType: 'A003',
            businessId: formModel.id || '',
            filename: file.name,
          };
        },
        headers: {
          Authorization: getToken(),
          'X-Access-Token': getToken(),
        },
        beforeUpload: (file) => {
          const isImage = file.type.startsWith('image/');
          if (!isImage) {
            message.error('只能上传图片!');
            return false; // Prevent upload
          }
          return isImage;
        },
      };
    },
  },
  {
    field: 'hkPrice',
    component: 'Divider',
    label: '阿里国际站平台图片',
  },
  {
    label: '',
    field: 'alibabaPic',
    helpMessage: '阿里国际站平台图片，最多上传15张图片',
    component: 'JImageUpload',
    componentProps: ({ formModel }) => {
      return {
        fileMax: 15,
        uploadPath: 's3',
        data: (file) => {
          return {
            fileType: 'A003',
            businessId: formModel.id || '',
            filename: file.name,
          };
        },
        headers: {
          Authorization: getToken(),
          'X-Access-Token': getToken(),
        },
        beforeUpload: (file) => {
          const isImage = file.type.startsWith('image/');
          if (!isImage) {
            message.error('只能上传图片!');
            return false; // Prevent upload
          }
          return isImage;
        },
      };
    },
  },
  {
    field: 'hkPrice',
    component: 'Divider',
    label: '其他图片',
  },
  {
    label: '',
    field: 'otherPics',
    helpMessage: '其他图片，最多上传15张图片',
    component: 'JImageUpload',
    componentProps: ({ formModel }) => {
      return {
        fileMax: 15,
        uploadPath: 'minio',
        data: (file) => {
          return {
            fileType: 'A003',
            businessId: formModel.id || '',
            filename: file.name,
          };
        },
        headers: {
          Authorization: getToken(),
          'X-Access-Token': getToken(),
        },
        beforeUpload: (file) => {
          const isImage = file.type.startsWith('image/');
          if (!isImage) {
            message.error('只能上传图片!');
            return false; // Prevent upload
          }
          return isImage;
        },
      };
    },
  },
];
export const formSchema07: FormSchema[] = [
  { label: '', field: 'id', component: 'Input', show: false },
  {
    label: '产品编码',
    field: 'goodsCode',
    component: 'Input',
    show: false,
  },
  {
    field: 'videoDivider1',
    component: 'Divider',
    label: '公司网站视频',
    componentProps: {
      orientation: 'left',
    },
  },
  {
    label: '',
    field: 'websiteVideos',
    component: 'JUpload',
    helpMessage: '解释文字',
    componentProps: ({ formModel }) => {
      return {
        fileMax: 5,
        uploadPath: 's3',
        fileType: 'video',
        text: '上传视频',
        data: (file) => {
          return {
            fileType: 'B001',
            businessId: formModel.id || '',
            filename: file.name,
          };
        },
        headers: {
          Authorization: getToken(),
          'X-Access-Token': getToken(),
        },
        beforeUpload: (file) => {
          const isVideo = file.type.startsWith('video/');
          if (!isVideo) {
            message.error('只能上传视频文件!');
            return false; // Prevent upload
          }
          return isVideo;
        },
        listType: 'text',
        showUploadList: {
          showPreviewIcon: true,
          showRemoveIcon: true,
          showDownloadIcon: false,
        },
      };
    },
  },
  {
    field: 'videoDivider2',
    component: 'Divider',
    label: '产品测试视频',
    componentProps: {
      orientation: 'left',
    },
  },
  {
    label: '',
    field: 'testVideos',
    component: 'JUpload',
    helpMessage: '解释文字',
    componentProps: ({ formModel }) => {
      return {
        fileMax: 5,
        uploadPath: 's3',
        fileType: 'video',
        text: '上传视频',
        data: (file) => {
          return {
            fileType: 'B002',
            businessId: formModel.id || '',
            filename: file.name,
          };
        },
        headers: {
          Authorization: getToken(),
          'X-Access-Token': getToken(),
        },
        beforeUpload: (file) => {
          const isVideo = file.type.startsWith('video/');
          if (!isVideo) {
            message.error('只能上传视频文件!');
            return false; // Prevent upload
          }
          return isVideo;
        },
        listType: 'text',
        showUploadList: {
          showPreviewIcon: true,
          showRemoveIcon: true,
          showDownloadIcon: false,
        },
        // onFilePreview: (file) => {
        //   if (file.url) {
        //     window.open(file.url, '_blank');
        //   } else if (file.originFileObj) {
        //     const url = URL.createObjectURL(file.originFileObj);
        //     window.open(url, '_blank');
        //   }
        // },
      };
    },
  },
  {
    field: 'videoDivider3',
    component: 'Divider',
    label: '随手拍视频',
    componentProps: {
      orientation: 'left',
    },
  },
  {
    label: '',
    field: 'casualVideos',
    component: 'JUpload',
    helpMessage: '解释文字',
    componentProps: ({ formModel }) => {
      return {
        fileMax: 5,
        uploadPath: 's3',
        fileType: 'video',
        text: '上传视频',
        data: (file) => {
          return {
            fileType: 'B003',
            businessId: formModel.id || '',
            filename: file.name,
          };
        },
        headers: {
          Authorization: getToken(),
          'X-Access-Token': getToken(),
        },
        beforeUpload: (file) => {
          const isVideo = file.type.startsWith('video/');
          if (!isVideo) {
            message.error('只能上传视频文件!');
            return false; // Prevent upload
          }
          return isVideo;
        },
        listType: 'text',
        showUploadList: {
          showPreviewIcon: true,
          showRemoveIcon: true,
          showDownloadIcon: false,
        },
        onPreview: (file) => {
          if (file.url) {
            window.open(file.url, '_blank');
          } else if (file.originFileObj) {
            const url = URL.createObjectURL(file.originFileObj);
            window.open(url, '_blank');
          }
        },
      };
    },
  },
  {
    field: 'videoDivider4',
    component: 'Divider',
    label: '其他视频',
    componentProps: {
      orientation: 'left',
    },
  },
  {
    label: '',
    field: 'otherVideos',
    component: 'JUpload',
    helpMessage: '解释文字',
    componentProps: ({ formModel }) => {
      return {
        fileMax: 5,
        uploadPath: 'minio',
        fileType: 'video',
        text: '上传视频',
        data: (file) => {
          return {
            fileType: 'B004',
            businessId: formModel.id || '',
            filename: file.name,
          };
        },
        headers: {
          Authorization: getToken(),
          'X-Access-Token': getToken(),
        },
        beforeUpload: (file) => {
          const isVideo = file.type.startsWith('video/');
          if (!isVideo) {
            message.error('只能上传视频文件!');
            return false; // Prevent upload
          }
          return isVideo;
        },
        listType: 'text',
        showUploadList: {
          showPreviewIcon: true,
          showRemoveIcon: true,
          showDownloadIcon: false,
        },
        onPreview: (file) => {
          if (file.url) {
            window.open(file.url, '_blank');
          } else if (file.originFileObj) {
            const url = URL.createObjectURL(file.originFileObj);
            window.open(url, '_blank');
          }
        },
      };
    },
  },
];
